#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_he_a2.info <<'%EOF%'
   cc2_r12_he_a2
   -----------
   Molecule:         He 
   Wave Function:    CC2-R12/A2/B / AhlrichsVDZ + AhlrichsVTZ
   Test Purpose:     Check CC2-R12/A2/B method with auxiliary basis 
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_he_a2.mol <<'%EOF%'
#
BASIS
Ahlrichs-VDZ Ahlrichs-VTZ
He

    2    3  X  Y  Z    .10E-99
 1     2.0    1    1
He     .000000000000000    .000000000000000    0.000000000000000      *
 2     2.0    1    1
He     .000000000000000    .000000000000000    0.000000000000000      *
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_he_a2.dal <<'%EOF%'
**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF INPUT
.THRESH
 1.0D-11
*CC INPUT
.CC2
.PRINT
 2  
.THRENR
 1.0D-11
.MAX IT
 300
*CCEXCI
.THREXC
 1.D-8
.NCCEXCI
 3 3 3 3 3 3 3 3 
*R12 INPUT
.NO HYB
#.R12XXL
#.NO A
#.NO A'
#.NO B'
#.NO 1
.CC2
 2B
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_he_a2.check
cat >>cc2_r12_he_a2.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#           Total SCF   energy:                    -2.8551604793
#           Total MP2-R12/B energy:                -2.8864043722
#           Total CC2-R12/B energy:                -2.8864107992
#
#  +=============================================================================+
#  |  sym. | Exci.  |        CC2-R12/B  Excitation energies            | ||T1||  |
#  |(spin, |        +------------------------------------------------------------+
#  | spat) |        |     Hartree    |       eV.      |     cm-1       |    %    |
#  +=============================================================================+
#  | ^1Ag  |    1   |     1.9375317  |      52.72292  |    425239.065  |  99.95  |
#  | ^1Ag  |    2   |     4.6229427  |     125.79667  |   1014618.651  |   0.20  |
#  | ^1Ag  |    3   |     5.3911760  |     146.70136  |   1183226.369  |   0.01  |
#  +=============================================================================+
# 

CRIT1=`$GREP "Total MP2-R12/B energy: * \-2\.8864043722" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/B ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/B energy: * \-2\.886410799." $log | wc -l`
TEST[2]=`expr	$CRIT2`
CTRL[2]=2
ERROR[2]="CC2-R12/B ENERGY NOT CORRECT"
#
CRIT3=`$GREP "\| \^1Ag  \|    1   \|     1\.93753..  \|      52\.7229.  \|    425239\....  \|  99\.95  \|" $log | wc -l`
TEST[3]=`expr	$CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/B 1A1 EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP "\| \^1Ag  \|    2   \|     4\.62294..  \|     125\.7966.  \|   1014618\....  \|   ( |0)\.20  \|" $log | wc -l`
TEST[4]=`expr	$CRIT4`
CTRL[4]=1
ERROR[4]="CC2-R12/B 2A1 EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP "\| \^1Ag  \|    3   \|     5\.39117..  \|     146\.7013.  \|   1183226\....  \|   ( |0)\.01  \|" $log | wc -l`
TEST[5]=`expr	$CRIT5`
CTRL[5]=1
ERROR[5]="CC2-R12/B 3A1 EXCITATION ENERGY NOT CORRECT"

PASSED=1
for i in 1 2 3 4 5
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
